package org.zezs.sync.mongo.plugs;

import jdk.nashorn.api.scripting.NashornScriptEngine;
import org.apache.commons.lang3.StringUtils;
import org.zezs.sync.mongo.RunTimeUtil;

import javax.script.ScriptException;
import java.io.InputStreamReader;
import java.io.Reader;

public class Plug {
    protected String jsFile;

    protected void initJs(NashornScriptEngine engine) throws ScriptException {
        if(!StringUtils.isBlank(jsFile)){
            Reader core = new InputStreamReader(RunTimeUtil.class.getResourceAsStream(jsFile));
            engine.eval(core);
        }

    }
    public void init(NashornScriptEngine engine) throws Exception{
        initJs(engine);
    };

}
